<template>
  <div class="common-body-wrapper">
    <search-header
      single-width="130"
      :searchList="searchList"
      @changeHeight="toRetTable"
      @confirmSearch="toSearch"
      :isNeedTree="true"
      :isCheckbox="true"
      :paramName="paramName"
      @setSelectedNode="setSelectedNode"
    ></search-header>
    <div class="common-table-tree-wrapper">
      <div class="common-table-wrapper">
        <multi-fun-table
          :sortColumn="notFormatColumn"
          :orderType="sortType"
          :fixed-cols="fixedCols"
          :is-reset-table="isResetTable"
          :theads-info="theadsInfo"
          :tbodys-info="tbodysInfo"
          @handleMultiCheck="handleMultiCheck"
          @handleSortColumn="handleSortColumn"
          @searchFn="getList"
          @getNextPage="getNextPage"
        >
          <div class="operate-btn-group" slot="operateBtnGroup">
            <a
              class="ake_btn ake_btn_text"
              v-if="isPermmited('PARKING_OPERATION:YTJPHOTORECORD:EXPORT')"
              @click.prevent="exportData()"
            >导出</a>
          </div>
          <template slot="tdCell" slot-scope="props">
            <el-table-column
              :fixed="props.fixed"
              :label="props.label"
              :min-width="props.minWidth"
              :width="props.width"
              :prop="props.prop"
              :sortable="props.sortable"
            >
              <template slot-scope="scope">
                <span v-if="'reno' == props.prop">{{scope.$index+1}}</span>
                <div v-else-if="'plateImageURL' == props.prop">
                  <!-- 无小图、无大图 -->
                  <span v-if="!scope.row['plateImageURL'] && !scope.row['carImageURL']">暂无图片</span>
                  <!-- 有小图 -->
                  <a
                    v-else
                    class="imgLink"
                    @click="showBigImgModal('bigPicModal', scope.row['carImageURL'])"
                  >
                    <img
                      style="width: 60px;height:30px;"
                      alt="无缩略图"
                      :src="scope.row.plateImageURL"
                      @error="handleImg($event)"
                    />
                  </a>
                </div>
                <span v-else-if="'channelType'==props.prop">{{scope.row[props.prop] | channelType}}</span>
                <span v-else-if="'photoType'==props.prop">{{scope.row[props.prop] | photoType}}</span>
                <span v-else-if="'recogTime'==props.prop">{{scope.row[props.prop] | timeFormat}}</span>
                <span v-else>{{ scope.row[props.prop] }}</span>
              </template>
            </el-table-column>
          </template>
        </multi-fun-table>

        <table-pagination :size="total" :cur-page="pageNumber" @backData="getPagination"></table-pagination>
      </div>
    </div>

    <!--选择停车场树-->
    <basic-modal ref="selectParkModal" width="400" customeClass="select-park-modal" static="true">
      <h3 slot="title">选择停车场</h3>
      <div class="modal-body" slot="modal-body">
        <div class="common-tree modal-tree-box">
          <ul id="ParkTree" name="ParkTree" class="ztree"></ul>
        </div>
      </div>
      <div class="modal-footer" slot="modal-footer">
        <button
          type="button"
          class="ake_btn ake_btn_text ake_btn_confirm"
          @click="selectParkSure()"
        >确认</button>
        <button class="ake_btn ake_btn_text modal-close" @click="closed('selectParkModal',2)">取消</button>
      </div>
    </basic-modal>

    <big-pic-modal ref="bigPicModal">
      <img
        slot="bigImgSlot"
        :src="bigImgPath | setImgPath"
        alt
        @error="imgError('../../', 'car', $event)"
      />
    </big-pic-modal>
  </div>
</template>

<script>
import common from "@mixins/common.js";
import stardardList from "@mixins/tables/stardardList.js";

//modal
import invokeModal from "@mixins/modal/invokeModal.js";
import BigPicModal from "@components/widgets/BigPicModal.vue";

// image
import images from "@mixins/image.js";

// 引进vue的js
import photo_record from "./js/photo_record.js";

export default {
  mixins: [common, stardardList, invokeModal, photo_record, images],
  components: {
    BigPicModal
  },
  data() {
    const today = [
      new Date(moment().format("YYYY-MM-DD 00:00:00")),
      new Date(moment().format("YYYY-MM-DD 23:59:59"))
    ];
    return {
      isResetTable: false,
      total: 0,
      fixedCols: 0,
      paramName: "query_parkId",
      searchList: [
        {
          index: 0,
          isShow: false,
          type: "text",
          name: "query_channelName",
          text: "通道名称",
          value: ""
        },
        {
          index: 1,
          isShow: false,
          type: "text",
          name: "query_carNo",
          text: "车牌号",
          value: ""
        },
        {
          index: 2,
          isShow: false,
          type: "datePicker",
          name: "since",
          text: "拍照时间",
          propName: "query_since,query_end",
          value: today,
          style: { width: "360px" }
        }
      ],
      theadsInfo: [
        {
          index: 1,
          isShow: false,
          prop: "parkName",
          text: "停车场",
          minWidth: 155
        },
        {
          index: 2,
          isShow: false,
          prop: "channelName",
          text: "通道名称",
          minWidth: 155
        },
        {
          index: 3,
          isShow: false,
          prop: "channelType",
          text: "通道类型",
          minWidth: 155
        },
        {
          index: 4,
          isShow: false,
          prop: "recogTime",
          text: "拍照时间",
          minWidth: 155
        },
        {
          index: 5,
          isShow: false,
          prop: "photoType",
          text: "抓拍类型",
          minWidth: 80
        },
        {
          index: 6,
          isShow: false,
          prop: "carNo",
          text: "车牌号",
          minWidth: 155
        },
        {
          index: 7,
          isShow: false,
          prop: "plateImageURL",
          text: "拍照图片",
          minWidth: 80
        },
        {
          index: 8,
          isShow: false,
          prop: "operatorName",
          text: "操作人",
          minWidth: 155
        }
      ],
      tbodysInfo: []
    };
  }
};
</script>